#ifndef LOGICQDCBOARD_H
#define LOGICQDCBOARD_H

#include "VmeModule.h"
#include "LogicPool/LogicInterfaceVME.h"
#include "LogicPool/LogicQDC.h"
#include "LogicPool/LogicIndicator.h"
#include "LogicPool/LogicDIO.h"
#include "LogicPool/LogicLogic.h"
#include "LogicPool/LogicCounter.h"


class LogicQDCBoard : VmeModule
{

  protected:

    LogicInterface * logicpool;
    LogicIndicator * led[8]; 
    LogicDIO       * dio[8];
    LogicQDC       * qdc[3];
    LogicLogic     * log[8];
    LogicCounter   * counter[2];

  public:
  
    LogicQDCBoard(int handle, unsigned int address) : VmeModule(handle, address) { Init(); };
  
    LogicInterface & GetInterface() { return *logicpool; };
    LogicIndicator & GetIndicator(int no = 1) { return *led[no-1]; };
    LogicDIO & GetDIO(int no = 1) { return *dio[no-1]; };
    LogicQDC & GetQDC(int no = 1) { return *qdc[no-1]; };
    LogicCounter & GetCounter(int no = 1) { return *counter[no-1]; };
    LogicLogic & GetLogic(int no = 1) { return *log[no-1]; };

    LogicQDC & operator[](int no) 
    {
        return * qdc[no -1];
    };

    void Clear()
    {
        for (int i = 0; i < 3; i++)
            qdc[i]->Clear();
    }

    void SetStartDelay(uint8_t time)
    {
        for (int i = 0; i < 3; i++)
            qdc[i]->SetStartDelay(time);
    }

    void SetStopDelay(uint8_t time)
    {
        for (int i = 0; i < 3; i++)
            qdc[i]->SetStopDelay(time);
    }

    void SetGateTime(uint8_t time)
    {
        for (int i = 0; i < 3; i++)
            qdc[i]->SetGateTime(time);
    }

    void Init();

    void Close()
    {
        logicpool->Close();
    };

};


#endif
